﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>发卡登记个人</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="${pageContext.request.contextPath }/scripts/boot.js" type="text/javascript"></script>
<style type="text/css">
    html, body
    {
        font-size:12px;
        padding:0;
        margin:0;
        border:0;
        height:100%;
    } 
</style>
</head>
<body>
  <fieldset style="border:solid 1px #aaa;padding:3px;">
    <legend >个人发放</legend> 
    <form id="form1" method="post">   
      <div style=" text-align:center;padding-left:11px;padding-bottom:5px;">
        <table style="table-layout:fixed;width:80%;">
          <tr>
            <td style="width:20%;white-space:nowrap;text-align:right;">社会保障卡号：</td>
            <td style="width:30%;"><input name="aac001"  class="mini-textbox" required="true" vtype="int;minLength:10" maxlength="10"  emptyText="请输入社会保障卡号" style="width:100%;" onenter="onKeyEnter"/></td>
            <td style="width:20%;white-space:nowrap;text-align:right;">姓名：</td>
            <td style="width:30%;"><input name="aac003" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false"  readonly="readonly" style="width:100%;"/></td>
          </tr>
          <tr>
            <td style="width:20%;white-space:nowrap;text-align:right;">劳动保障证号：</td>
            <td style="width:30%;"><input name="aab001" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="readonly" style="width:100%;"/></td>
            <td style="width:20%;white-space:nowrap;text-align:right;">性别：</td>
            <td style="width:30%;"><input name="aac004" class="mini-combobox" inputStyle="background:rgb(241,241,243)" allowInput="false"  style="width:100%;"readonly="readonly"
            url="${pageContext.request.contextPath }/GRfk.do?method=getaac004&lx=AAC004" valueField="aaa102" textField="aaa103" /> </td>          
          </tr>
          <tr>
            <td style="width:20%;white-space:nowrap;text-align:right;">制卡批次：</td>
            <td style="width:30%;"><input name="aaz001" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="readonly" style="width:100%;"/></td>
            <td style="width:20%;white-space:nowrap;text-align:right;">盒号：</td>
            <td style="width:30%;"><input name="aaz632" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="readonly" style="width:100%;"/>
             <input name="aaz411" class="mini-hidden" style="width:100%"/></td></td>
          </tr>
        </table>
      </div>
      <div style="text-align:center;padding:10px;">
        <a class="mini-button" onclick="onOk" iconCls="icon-ok"  style="width:60px;margin-right:20px;">确认</a>
        <a class="mini-button" onclick="onReset" iconCls="icon-remove"  style="width:60px;margin-right:20px;">重置</a>    
      </div>
    </form>
  </fieldset>
<script type="text/javascript">
    mini.parse();  
    var form = new mini.Form("form1");
    function onKeyEnter()
        {
          var aac001 = mini.getbyName("aac001").getValue().trim();                     
           $.ajax({               
                    url: "/sbk/GRfk.do?method=getgrunitdata",
                    cache: false,
                    data:{id:aac001},
                    success: function (text) { 
                        if(text != "null") {              
                        var o = mini.decode(text);                      
                        mini.getbyName("aac004").setValue(o.aac004);                                       
                        mini.getbyName("aac003").setValue(o.aac003); 
                        mini.getbyName("aaz632").setValue(o.aaz632);
                        mini.getbyName("aaz001").setValue(o.aaz001);                         
                        mini.getbyName("aab001").setValue(o.aab001);  
                        mini.getbyName("aaz411").setValue(o.aaz411); 
                        mini.getbyName("aac001").setEnabled(false);
                        }
                        else {
                           form.clear();
                           mini.alert("没有发放的卡");
                        }                
                    }
                });        
        }
       function onOk(e) {
        
           SaveData();
        }
        
         function SaveData() {
            var aac001 = mini.getbyName("aac001").getValue().trim(); 
			var o = form.getData();				
			form.validate();
			if (form.isValid() == false)
			return;
			if(form.isValid()==true){
      	    mini.mask({el: document.body,cls: 'mini-mask-loading',html: '登记中...'});
      	    } 
			var json = mini.encode([o]);
			$.ajax({
				url : "/sbk/GRfk.do?method=savegrunit",
				type : 'post',
				data : {
					data : json,id:aac001
				},
				cache : false,
				success : function(text) {	
				     mini.unmask();				  				   			
					if("0"==text)
				{
				   mini.alert("登记成功");
				   mini.getbyName("aac001").setEnabled(true);		   
				}
				else
				{
				 mini.alert("登记失败:"+text);
				 mini.getbyName("aac001").setEnabled(true);
				}	
				 form.clear();								
				},
				error : function(jqXHR, textStatus, errorThrown) {
					mini.alert(jqXHR.responseText);					
				}
			});
      	    

		}	
    
     function onReset(e) {
			form.clear();
			mini.getbyName("aac001").setEnabled(true);
			
		}
</script>
</body>
</html>
